package com.xiaolanshu.exception;

import com.xiaolanshu.vo.ErrorResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice //全局异常捕获、自定义异常捕获
public class ExceptionAdvice {

    @ExceptionHandler(BusinessException.class)
    public ResponseEntity handlerBusinessException(BusinessException businessException){

        businessException.printStackTrace();
        return ResponseEntity.status(500).body(businessException.getErrorResult());

    }

}
